"""
@file Junior.py
@author GalaktiK (jacobliu001@qq.com)
@version 1.0
@date 2020-12-25

@copyright Copyright (c) 2020, Published under License GPLv2
"""
for TC in range(5):
    s, d, r = map(int, input().split())
    print("%d. %d"%(TC+1,sum([(9 if (s+d*x)%9==0 else (s+d*x)%9) for x in range(r*(r-1)//2, r*(r+1)//2)])))
